package com.example.demo.business.service.impl;

import java.time.LocalDate;
import java.time.LocalDateTime;

import org.springframework.stereotype.Service;

import com.example.common.util.IdUtil;
import com.example.demo.business.feign.MemberFeign;
import com.example.demo.business.feign.TradeFeign;
import com.example.demo.business.model.Player;
import com.example.demo.business.model.TradeOrderRequest;
import com.example.demo.business.service.BusinessService;

import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;

@Service
public class BusinessImpl implements BusinessService {

    @Resource
    private MemberFeign memberFeign;
    @Resource
    private TradeFeign  tradeFeign;

    @Override
    @GlobalTransactional
    public void test() {

        Player player = new Player() //
            .setName("猫咪") //
            .setEmail("mmm@qqq") //
        ;
        memberFeign.savePlayer(player);

        TradeOrderRequest tradeOrderRequest = new TradeOrderRequest() //
            .setDate(LocalDate.now()) //
            .setMemberId(IdUtil.getId()) //
            .setCreateTime(LocalDateTime.now()) //
        ;
        tradeFeign.save(tradeOrderRequest);

    }

}
